<template>
  <div class="title">开发者注册</div>
  <el-form :model="user" label-width="120px">
    <el-form-item label="登陆名">
      <el-input v-model="user.userNm" />
    </el-form-item>
    <el-form-item label="昵 &nbsp;&nbsp;称">
      <el-input v-model="user.nickNm" />
    </el-form-item>
    <el-form-item label="生 &nbsp;&nbsp;日">
        <el-date-picker
            v-model="user.birth"
            align="right"
            type="date"
            placeholder="选择日期"
            :picker-options="pickerOptions">
        </el-date-picker>
    </el-form-item>
    <el-form-item label="性  &nbsp;&nbsp;别">
      <el-radio-group v-model="user.sex">
        <el-radio label="男" value="男"/>
        <el-radio label="女" value="女"/>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="是否应届" prop="delivery">
      <el-switch v-model="user.delivery"></el-switch>
    </el-form-item>
    <el-form-item label="所学专业">
      <el-select v-model="user.major" placeholder="请选择所学专业">
        <el-option label="计算机科学与技术专业" value="01" />
        <el-option label="软件工程专业" value="02" />
        <el-option label="物联网工程专业" value="03" />
        <el-option label="空间信息与数字技术专业" value="04" />
      </el-select>
    </el-form-item>
    <el-form-item label="我的技能">
      <el-checkbox-group v-model="user.hobby">
        <el-checkbox label="Java" name="java" />
        <el-checkbox label="PHP" name="php" />
        <el-checkbox label="Python" name="python" />
        <el-checkbox label="VUE" name="vue" />
        <el-checkbox label="TypeScript" name="ts" />
      </el-checkbox-group>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">注册</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
/* eslint-disable */

import { ElMessageBox } from 'element-plus'
import axios from 'axios'

export default {
  name: 'Register',
  data() {
    return {
      user: {
        userNm: '',
        nickNm:'',
        birth:'',
        delivery:false,
        major:'',
        hobby: [],
        sex: '',
      },
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      }
    }
  },
  methods: {
    onSubmit() {

      axios.post('http://127.0.0.1:9083/developer/register',JSON.stringify( this.user), {headers: {
        'Content-Type':'application/json;charset=UTF-8',//设置请求头请求格式为JSON
   },}).then(
        (res) => {
          ElMessageBox.alert('用户注册', '注册成功', {

            confirmButtonText: 'OK',
          })
        }
      )

    }

  }
}
</script>

<style>
.title{
  font-size: large;
  width: 100px;
  margin: 10px auto ;
}
</style>
